<%@page import="cn.com.xf.common.StringUtil"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	
	List<Tbdamagedgoods> list = (List<Tbdamagedgoods>)request.getAttribute("list");
	DamagedgoodsForm form = (DamagedgoodsForm)request.getAttribute("command");
	String recedateStart = StringUtils.isNotBlank(form.getRecedateStart())?form.getRecedateStart():"";
	String recedateEnd = StringUtils.isNotBlank(form.getRecedateEnd())?form.getRecedateEnd():"";
	UserInfo user = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	String userid = user.getEmployId();
	String username = user.getName();
	String siteid = user.getSiteId();
	String sitename = user.getSiteName();
%>
<div>
	<input type="hidden" id="userid" value="<%=userid%>"/>
	<input type="hidden" id="username" value="<%=username%>"/>
	<input type="hidden" id="siteid" value="<%=siteid%>"/>
	<input type="hidden" id="sitename" value="<%=sitename%>"/>
	<table id="unknownTable" class="easyui-datagrid" title="不明件查看"
			data-options="singleSelect:true,toolbar:'#tb',nowrap:false">
		<thead>
			<tr>
				<th data-options="field:'goodsid',width:80,align:'center',halign: 'center'" rowspan="2">物品编号</th>
				<th data-options="field:'imgUrl',width:100,align:'center',halign: 'center'" rowspan="2">整体图</th>
				<th data-options="field:'weight',width:60,align:'center',halign: 'center'" rowspan="2">重量(KG)</th>
				<th data-options="field:'entsitename',width:80,align:'center',halign: 'center'" rowspan="2">接货网点</th>
				<th data-options="field:'receclass',width:80,align:'center',halign: 'center'" rowspan="2">接货班次</th>
				<th data-options="field:'recedate',width:80,align:'center',halign: 'center'" rowspan="2">接货时间</th>
				<th data-options="field:'entusername',width:70,align:'center',halign: 'center'" rowspan="2">登记人</th>
				<th data-options="field:'memo',width:100,align:'center',halign: 'center'" rowspan="2">描述</th>
				<th data-options="field:'status',width:70,align:'center',halign: 'center'" rowspan="2">状态</th>
				<th colspan="4">认领申请信息</th>
				<th colspan="4">认领确认信息</th>
			</tr>
			<tr>
				<th data-options="field:'applyusername',width:70,align:'center',halign: 'center'">申请人</th>
				<th data-options="field:'applysname',width:80,align:'center',halign: 'center'">网点</th>
				<th data-options="field:'applytime',width:80,align:'center',halign: 'center'">时间</th>
				<th data-options="field:'applymemo',width:100,align:'center',halign: 'center'">描述</th>
				<th data-options="field:'verifyusername',width:70,align:'center',halign: 'center'">确认人</th>
				<th data-options="field:'verifysname',width:80,align:'center',halign: 'center'">网点</th>
				<th data-options="field:'verifytime',width:80,align:'center',halign: 'center'">时间</th>
				<th data-options="field:'verifymemo',width:100,align:'center',halign: 'center'">描述</th>
			</tr>
		</thead>
		<tbody>
			<%if(list!=null && list.size() > 0){
        		for(Tbdamagedgoods goods:list){%>
        			<tr s="<%=goods.getSeqid() %>">
        				<td><i s="<%=goods.getSeqid() %>"></i><%=(null!=goods.getGoodsid())?goods.getGoodsid()+"":"" %></td>
        				<td><div style="margin: 5px">
        						<input width="80" height="80" type="image" onClick="javascript:XF.Goods.getImgURL('<%=goods.getSeqid() %>')" src="<%=goods.getImgUrl()!=null?goods.getImgUrl():request.getContextPath()+"/images/logo_big.jpg" %>" border="0" />
        						</div></td>
        				<td><%=goods.getWeight()!=null?goods.getWeight():"" %></td>
        				<td><%=goods.getEntsitename()!=null?goods.getEntsitename():"" %></td>
        				<td><%=goods.getRececlass()!=null?goods.getRececlass():"" %></td>
        				<td><%=goods.getEntertime()!=null?DateFormatUtils.format(goods.getEntertime().getTime(), "yyyy-MM-dd HH:mm"):"" %></td>
        				<td><%=goods.getEntusername()!=null?goods.getEntusername():"" %></td>
        				<td><%=goods.getMemo()!=null?goods.getMemo():"" %></td>
        				<td><div id="sta<%=goods.getSeqid() %>"><%if(goods.getApplysta() == 0 && !siteid.equals(goods.getEntersite())){ %><!-- 未认领0与不是接货站点 -->
        					<div><a href="javascript:XF.Goods.applyUnknown('<%=goods.getSeqid()%>','<%=goods.getGoodsid()!=null?goods.getGoodsid():""%>')" class="easyui-linkbutton" style="color: #1e71b1;">认领申请</a></div>
        					<%}else if(goods.getApplysta() == 1 && !siteid.equals(goods.getEntersite())){%><!-- 认领1与不是接货站点 -->
        					<div><a href="javascript:XF.Goods.lookApply('<%=goods.getSeqid()%>','1')" class="easyui-linkbutton" >认领查看</a>
        					<a href="javascript:XF.Goods.applyUnknown('<%=goods.getSeqid()%>','<%=goods.getGoodsid()!=null?goods.getGoodsid():""%>')" class="easyui-linkbutton" style="color: #1e71b1;">认领申请</a></div>
        					<%}else if(goods.getApplysta() == 1 && siteid.equals(goods.getEntersite())){%><!-- 认领1与接货站点 -->
        					<div><a href="javascript:XF.Goods.lookApply('<%=goods.getSeqid()%>','0')" class="easyui-linkbutton" style="color: red;">认领审核</a></div>
        					<%}else if(goods.getApplysta() == 2 && siteid.equals(goods.getEntersite())){%><!-- 认领2与接货站点 -->
        					<div><a href="javascript:XF.Goods.lookApply('<%=goods.getSeqid()%>','2')" class="easyui-linkbutton">认领查看</a></div>
        					<%}else if(goods.getApplysta() == 2 && !siteid.equals(goods.getEntersite())){%><!-- 认领2与不是接货站点 -->
        					<div><a href="javascript:XF.Goods.lookApply('<%=goods.getSeqid()%>','3')" class="easyui-linkbutton">认领查看</a></div>
        					<%} %>
        					</div>
        				</td>
        				<td><%=goods.getApplyusername()!=null?goods.getApplyusername():"" %></td>
        				<td><%=goods.getApplysname()!=null?goods.getApplysname():""%></td>
        				<td><%=goods.getApplytime()!=null?DateFormatUtils.format(goods.getApplytime().getTime(), "yyyy-MM-dd HH:mm"):""%></td>
        				<td><%=goods.getApplymemo()!=null?goods.getApplymemo():""%></td>
        				<td><%=goods.getVerifyusername()!=null?goods.getVerifyusername():""%></td>
        				<td><%=goods.getVerifysname()!=null?goods.getVerifysname():""%></td>
        				<td><%=goods.getVerifytime()!=null?DateFormatUtils.format(goods.getVerifytime().getTime(), "yyyy-MM-dd HH:mm"):""%></td>
        				<td><%=goods.getVerifymemo()!=null?goods.getVerifymemo():""%></td>
        			</tr>
        			<%}}%>
		
		</tbody>
	</table>
	<div id="tb" style="padding:5px;height:auto">
    		<div style="margin-bottom:5px;margin-top: 5px;margin-left: 10px">
    			物品编号：<input type="text" id="goodsid" name="goodsid" style="height: 24px;width: 150px;"  value="<%=form.getGoodsid() %>"/>&nbsp;&nbsp;&nbsp;&nbsp;
    			接货时间：&nbsp;<input  id="recedateStart" name="recedateStart"  type="text" style="height: 24px;width: 75px;"  onfocus="WdatePicker({errDealMode:1,dateFmt:'yyyy-MM-dd',minDate:'2017-01-01',maxDate:'%y-%M-%d'})" value="<%=recedateStart %>">
				&nbsp;&nbsp;至：<input id="recedateEnd" name="recedateEnd"  type="text" style="height: 24px;width: 75px"  onfocus="WdatePicker({errDealMode:1,dateFmt:'yyyy-MM-dd',minDate:'2017-01-01',maxDate:'%y-%M-%d'})" value="<%= recedateEnd%>">&nbsp;&nbsp;&nbsp;&nbsp;
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;描述：<input type="text" id="memo" name="memo" style="height: 24px;width: 150px;"  value="<%=form.getMemo() %>"/>
    		</div>
    		<div style="margin-left: 10px">
    			搜索类别：<select id="typesite" name="typesite" class="easyui-combobox" style="width:80px;">
    				<option value="0">全部</option>
    				<option value="1">认领</option>
    				<option value="2">审核</option>
    			</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	&nbsp;&nbsp;&nbsp;&nbsp;
				接货网点：
				<select id="entersite" name="entersite" class="easyui-combobox" style="width:190px;"></select>
				&nbsp;&nbsp;&nbsp;
				接货班次：<select id="receclass" name="receclass" class="easyui-combobox" style="width:70px;">
				<option value="中班">中班</option>
				<option value="晚班">晚班</option>
			</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    			<a href="javascript:XF.Goods.listUnknownSearch('')" class="easyui-linkbutton" style="margin-bottom:5px" iconCls="icon-search">搜索</a>
    		</div>
    	</div>
	<div class="pagination paginationFixWidth">
		<monggoTag:pagination 
		href="unknown_search"
		pageSize="<%=form.getPageSize()%>" 
		totalRecord="<%=form.getTotalRecord() %>" 
		currentPage="<%=form.getPageNum() %>">
		</monggoTag:pagination> 
	</div>
</div>
<style type="text/css">
.datagrid-row {  
    height: 90px;  
    text-align:center;  
  }  
</style>
 <script>
 	$("#unknownTable").datagrid({fitColumns:false});
 	$(".easyui-linkbutton").linkbutton();
 	$(".easyui-combobox").combobox();
    var entersite = '<%=form.getEntersite() %>';
    $('#entersite').combobox({
		url:global.contextPath + '/company/sites',
		valueField:'siteid',
		textField:'sitename',		
	    panelHeight: '300',
        value:entersite,
	    onHidePanel:function(){
			var _options = $(this).combobox('options');  
		    var _data = $(this).combobox('getData');/* 下拉框所有选项 */  
		    var _value = $(this).combobox('getValue');/* 用户输入的值 */  
		    var _b = false;/* 标识是否在下拉列表中找到了用户输入的字符 */  
		    for (var i = 0; i < _data.length; i++) {  
		        if (_data[i][_options.valueField] == _value) {  
		            _b=true;  
		            break;  
		        }  
		    }  
		    if(!_b){  
		        $(this).combobox('setValue','');
		    } 
        },
	});
	var siteid = '<%=siteid%>';
	$(".combo").css("margin-bottom","5px");
	var typesite = '<%=form.getTypesite()%>';
	$("#typesite").combobox({
 		value:typesite,
 		onChange:function(typeval){
	 		if(typeval == '2'){
		 		$("#entersite").combobox('setValue',siteid);
	 		}else if(typeval =='1'){
		 		var typeentsite = $('#entersite').combobox('getValue');
		 		if(typeentsite == siteid){
			 		$('#entersite').combobox('setValue','');
		 		}
	 		}
 		}
	});
	var receclass = '<%=form.getRececlass() %>';
	$('#receclass').combobox('setValue', receclass);

</script>

